package jp.ac.tohoku.ecei.cl.www.base;

import java.io.*;
import java.util.ArrayList;

public class TabbedTextParser {
  
    public static ArrayList<String[]> parse (InputStream is) {
        ArrayList<String[]> elements = new ArrayList<String[]>();
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8") );
            String line;
            while( (line = reader.readLine() ) != null) {
                if (line.equals("")) { continue; }
                if (line.charAt(0) == '#') { continue; }
                elements.add(line.split("\\s"));
                /*
                String[] els = elements.get(elements.size()-1);
                for (int i = 0; i < els.length; i++) {
                    System.err.println(i+" "+els[i]);
                }
                */
            }
            reader.close();
        } catch (FileNotFoundException e) {
            System.out.println(e);
        } catch (IOException e) {
            System.out.println(e);
        }
        return elements;
    }
}
